<?php
	/**
	 * This is a MetaControl class, providing a QForm or QPanel access to event handlers
	 * and QControls to perform the Create, Edit, and Delete functionality
	 * of the Articlemusictracks class.  This code-generated class
	 * contains all the basic elements to help a QPanel or QForm display an HTML form that can
	 * manipulate a single Articlemusictracks object.
	 *
	 * To take advantage of some (or all) of these control objects, you
	 * must create a new QForm or QPanel which instantiates a ArticlemusictracksMetaControl
	 * class.
	 *
	 * Any and all changes to this file will be overwritten with any subsequent
	 * code re-generation.
	 * 
	 * @package My Application
	 * @subpackage MetaControls
	 * property-read Articlemusictracks $Articlemusictracks the actual Articlemusictracks data class being edited
	 * property QLabel $IdControl
	 * property-read QLabel $IdLabel
	 * property QListBox $ReferenceIdControl
	 * property-read QLabel $ReferenceIdLabel
	 * property QTextBox $DiscNumberControl
	 * property-read QLabel $DiscNumberLabel
	 * property QTextBox $TrackNumberControl
	 * property-read QLabel $TrackNumberLabel
	 * property QTextBox $TrackTitleControl
	 * property-read QLabel $TrackTitleLabel
	 * property-read string $TitleVerb a verb indicating whether or not this is being edited or created
	 * property-read boolean $EditMode a boolean indicating whether or not this is being edited or created
	 */

	class ArticlemusictracksMetaControlGen extends QBaseClass {
		// General Variables
		protected $objArticlemusictracks;
		protected $objParentObject;
		protected $strTitleVerb;
		protected $blnEditMode;

		// Controls that allow the editing of Articlemusictracks's individual data fields
		protected $lblId;
		protected $lstReferenceIdObject;
		protected $txtDiscNumber;
		protected $txtTrackNumber;
		protected $txtTrackTitle;

		// Controls that allow the viewing of Articlemusictracks's individual data fields
		protected $lblReferenceId;
		protected $lblDiscNumber;
		protected $lblTrackNumber;
		protected $lblTrackTitle;

		// QListBox Controls (if applicable) to edit Unique ReverseReferences and ManyToMany References

		// QLabel Controls (if applicable) to view Unique ReverseReferences and ManyToMany References


		/**
		 * Main constructor.  Constructor OR static create methods are designed to be called in either
		 * a parent QPanel or the main QForm when wanting to create a
		 * ArticlemusictracksMetaControl to edit a single Articlemusictracks object within the
		 * QPanel or QForm.
		 *
		 * This constructor takes in a single Articlemusictracks object, while any of the static
		 * create methods below can be used to construct based off of individual PK ID(s).
		 *
		 * @param mixed $objParentObject QForm or QPanel which will be using this ArticlemusictracksMetaControl
		 * @param Articlemusictracks $objArticlemusictracks new or existing Articlemusictracks object
		 */
		 public function __construct($objParentObject, Articlemusictracks $objArticlemusictracks) {
			// Setup Parent Object (e.g. QForm or QPanel which will be using this ArticlemusictracksMetaControl)
			$this->objParentObject = $objParentObject;

			// Setup linked Articlemusictracks object
			$this->objArticlemusictracks = $objArticlemusictracks;

			// Figure out if we're Editing or Creating New
			if ($this->objArticlemusictracks->__Restored) {
				$this->strTitleVerb = QApplication::Translate('Edit');
				$this->blnEditMode = true;
			} else {
				$this->strTitleVerb = QApplication::Translate('Create');
				$this->blnEditMode = false;
			}
		 }

		/**
		 * Static Helper Method to Create using PK arguments
		 * You must pass in the PK arguments on an object to load, or leave it blank to create a new one.
		 * If you want to load via QueryString or PathInfo, use the CreateFromQueryString or CreateFromPathInfo
		 * static helper methods.  Finally, specify a CreateType to define whether or not we are only allowed to 
		 * edit, or if we are also allowed to create a new one, etc.
		 * 
		 * @param mixed $objParentObject QForm or QPanel which will be using this ArticlemusictracksMetaControl
		 * @param integer $intId primary key value
		 * @param QMetaControlCreateType $intCreateType rules governing Articlemusictracks object creation - defaults to CreateOrEdit
 		 * @return ArticlemusictracksMetaControl
		 */
		public static function Create($objParentObject, $intId = null, $intCreateType = QMetaControlCreateType::CreateOrEdit) {
			// Attempt to Load from PK Arguments
			if (strlen($intId)) {
				$objArticlemusictracks = Articlemusictracks::Load($intId);

				// Articlemusictracks was found -- return it!
				if ($objArticlemusictracks)
					return new ArticlemusictracksMetaControl($objParentObject, $objArticlemusictracks);

				// If CreateOnRecordNotFound not specified, throw an exception
				else if ($intCreateType != QMetaControlCreateType::CreateOnRecordNotFound)
					throw new QCallerException('Could not find a Articlemusictracks object with PK arguments: ' . $intId);

			// If EditOnly is specified, throw an exception
			} else if ($intCreateType == QMetaControlCreateType::EditOnly)
				throw new QCallerException('No PK arguments specified');

			// If we are here, then we need to create a new record
			return new ArticlemusictracksMetaControl($objParentObject, new Articlemusictracks());
		}

		/**
		 * Static Helper Method to Create using PathInfo arguments
		 *
		 * @param mixed $objParentObject QForm or QPanel which will be using this ArticlemusictracksMetaControl
		 * @param QMetaControlCreateType $intCreateType rules governing Articlemusictracks object creation - defaults to CreateOrEdit
		 * @return ArticlemusictracksMetaControl
		 */
		public static function CreateFromPathInfo($objParentObject, $intCreateType = QMetaControlCreateType::CreateOrEdit) {
			$intId = QApplication::PathInfo(0);
			return ArticlemusictracksMetaControl::Create($objParentObject, $intId, $intCreateType);
		}

		/**
		 * Static Helper Method to Create using QueryString arguments
		 *
		 * @param mixed $objParentObject QForm or QPanel which will be using this ArticlemusictracksMetaControl
		 * @param QMetaControlCreateType $intCreateType rules governing Articlemusictracks object creation - defaults to CreateOrEdit
		 * @return ArticlemusictracksMetaControl
		 */
		public static function CreateFromQueryString($objParentObject, $intCreateType = QMetaControlCreateType::CreateOrEdit) {
			$intId = QApplication::QueryString('intId');
			return ArticlemusictracksMetaControl::Create($objParentObject, $intId, $intCreateType);
		}



		///////////////////////////////////////////////
		// PUBLIC CREATE and REFRESH METHODS
		///////////////////////////////////////////////

		/**
		 * Create and setup QLabel lblId
		 * @param string $strControlId optional ControlId to use
		 * @return QLabel
		 */
		public function lblId_Create($strControlId = null) {
			$this->lblId = new QLabel($this->objParentObject, $strControlId);
			$this->lblId->Name = QApplication::Translate('Id');
			if ($this->blnEditMode)
				$this->lblId->Text = $this->objArticlemusictracks->Id;
			else
				$this->lblId->Text = 'N/A';
			return $this->lblId;
		}

		/**
		 * Create and setup QListBox lstReferenceIdObject
		 * @param string $strControlId optional ControlId to use
		 * @return QListBox
		 */
		public function lstReferenceIdObject_Create($strControlId = null) {
			$this->lstReferenceIdObject = new QListBox($this->objParentObject, $strControlId);
			$this->lstReferenceIdObject->Name = QApplication::Translate('Reference Id Object');
			$this->lstReferenceIdObject->AddItem(QApplication::Translate('- Select One -'), null);
			$objReferenceIdObjectArray = Articlemusic::LoadAll();
			if ($objReferenceIdObjectArray) foreach ($objReferenceIdObjectArray as $objReferenceIdObject) {
				$objListItem = new QListItem($objReferenceIdObject->__toString(), $objReferenceIdObject->Id);
				if (($this->objArticlemusictracks->ReferenceIdObject) && ($this->objArticlemusictracks->ReferenceIdObject->Id == $objReferenceIdObject->Id))
					$objListItem->Selected = true;
				$this->lstReferenceIdObject->AddItem($objListItem);
			}
			return $this->lstReferenceIdObject;
		}

		/**
		 * Create and setup QLabel lblReferenceId
		 * @param string $strControlId optional ControlId to use
		 * @return QLabel
		 */
		public function lblReferenceId_Create($strControlId = null) {
			$this->lblReferenceId = new QLabel($this->objParentObject, $strControlId);
			$this->lblReferenceId->Name = QApplication::Translate('Reference Id Object');
			$this->lblReferenceId->Text = ($this->objArticlemusictracks->ReferenceIdObject) ? $this->objArticlemusictracks->ReferenceIdObject->__toString() : null;
			return $this->lblReferenceId;
		}

		/**
		 * Create and setup QTextBox txtDiscNumber
		 * @param string $strControlId optional ControlId to use
		 * @return QTextBox
		 */
		public function txtDiscNumber_Create($strControlId = null) {
			$this->txtDiscNumber = new QTextBox($this->objParentObject, $strControlId);
			$this->txtDiscNumber->Name = QApplication::Translate('Disc Number');
			$this->txtDiscNumber->Text = $this->objArticlemusictracks->DiscNumber;
			$this->txtDiscNumber->MaxLength = Articlemusictracks::DiscNumberMaxLength;
			return $this->txtDiscNumber;
		}

		/**
		 * Create and setup QLabel lblDiscNumber
		 * @param string $strControlId optional ControlId to use
		 * @return QLabel
		 */
		public function lblDiscNumber_Create($strControlId = null) {
			$this->lblDiscNumber = new QLabel($this->objParentObject, $strControlId);
			$this->lblDiscNumber->Name = QApplication::Translate('Disc Number');
			$this->lblDiscNumber->Text = $this->objArticlemusictracks->DiscNumber;
			return $this->lblDiscNumber;
		}

		/**
		 * Create and setup QTextBox txtTrackNumber
		 * @param string $strControlId optional ControlId to use
		 * @return QTextBox
		 */
		public function txtTrackNumber_Create($strControlId = null) {
			$this->txtTrackNumber = new QTextBox($this->objParentObject, $strControlId);
			$this->txtTrackNumber->Name = QApplication::Translate('Track Number');
			$this->txtTrackNumber->Text = $this->objArticlemusictracks->TrackNumber;
			$this->txtTrackNumber->MaxLength = Articlemusictracks::TrackNumberMaxLength;
			return $this->txtTrackNumber;
		}

		/**
		 * Create and setup QLabel lblTrackNumber
		 * @param string $strControlId optional ControlId to use
		 * @return QLabel
		 */
		public function lblTrackNumber_Create($strControlId = null) {
			$this->lblTrackNumber = new QLabel($this->objParentObject, $strControlId);
			$this->lblTrackNumber->Name = QApplication::Translate('Track Number');
			$this->lblTrackNumber->Text = $this->objArticlemusictracks->TrackNumber;
			return $this->lblTrackNumber;
		}

		/**
		 * Create and setup QTextBox txtTrackTitle
		 * @param string $strControlId optional ControlId to use
		 * @return QTextBox
		 */
		public function txtTrackTitle_Create($strControlId = null) {
			$this->txtTrackTitle = new QTextBox($this->objParentObject, $strControlId);
			$this->txtTrackTitle->Name = QApplication::Translate('Track Title');
			$this->txtTrackTitle->Text = $this->objArticlemusictracks->TrackTitle;
			$this->txtTrackTitle->TextMode = QTextMode::MultiLine;
			return $this->txtTrackTitle;
		}

		/**
		 * Create and setup QLabel lblTrackTitle
		 * @param string $strControlId optional ControlId to use
		 * @return QLabel
		 */
		public function lblTrackTitle_Create($strControlId = null) {
			$this->lblTrackTitle = new QLabel($this->objParentObject, $strControlId);
			$this->lblTrackTitle->Name = QApplication::Translate('Track Title');
			$this->lblTrackTitle->Text = $this->objArticlemusictracks->TrackTitle;
			return $this->lblTrackTitle;
		}



		/**
		 * Refresh this MetaControl with Data from the local Articlemusictracks object.
		 * @param boolean $blnReload reload Articlemusictracks from the database
		 * @return void
		 */
		public function Refresh($blnReload = false) {
			if ($blnReload)
				$this->objArticlemusictracks->Reload();

			if ($this->lblId) if ($this->blnEditMode) $this->lblId->Text = $this->objArticlemusictracks->Id;

			if ($this->lstReferenceIdObject) {
					$this->lstReferenceIdObject->RemoveAllItems();
				$this->lstReferenceIdObject->AddItem(QApplication::Translate('- Select One -'), null);
				$objReferenceIdObjectArray = Articlemusic::LoadAll();
				if ($objReferenceIdObjectArray) foreach ($objReferenceIdObjectArray as $objReferenceIdObject) {
					$objListItem = new QListItem($objReferenceIdObject->__toString(), $objReferenceIdObject->Id);
					if (($this->objArticlemusictracks->ReferenceIdObject) && ($this->objArticlemusictracks->ReferenceIdObject->Id == $objReferenceIdObject->Id))
						$objListItem->Selected = true;
					$this->lstReferenceIdObject->AddItem($objListItem);
				}
			}
			if ($this->lblReferenceId) $this->lblReferenceId->Text = ($this->objArticlemusictracks->ReferenceIdObject) ? $this->objArticlemusictracks->ReferenceIdObject->__toString() : null;

			if ($this->txtDiscNumber) $this->txtDiscNumber->Text = $this->objArticlemusictracks->DiscNumber;
			if ($this->lblDiscNumber) $this->lblDiscNumber->Text = $this->objArticlemusictracks->DiscNumber;

			if ($this->txtTrackNumber) $this->txtTrackNumber->Text = $this->objArticlemusictracks->TrackNumber;
			if ($this->lblTrackNumber) $this->lblTrackNumber->Text = $this->objArticlemusictracks->TrackNumber;

			if ($this->txtTrackTitle) $this->txtTrackTitle->Text = $this->objArticlemusictracks->TrackTitle;
			if ($this->lblTrackTitle) $this->lblTrackTitle->Text = $this->objArticlemusictracks->TrackTitle;

		}



		///////////////////////////////////////////////
		// PROTECTED UPDATE METHODS for ManyToManyReferences (if any)
		///////////////////////////////////////////////





		///////////////////////////////////////////////
		// PUBLIC ARTICLEMUSICTRACKS OBJECT MANIPULATORS
		///////////////////////////////////////////////

		/**
		 * This will save this object's Articlemusictracks instance,
		 * updating only the fields which have had a control created for it.
		 */
		public function SaveArticlemusictracks() {
			try {
				// Update any fields for controls that have been created
				if ($this->lstReferenceIdObject) $this->objArticlemusictracks->ReferenceId = $this->lstReferenceIdObject->SelectedValue;
				if ($this->txtDiscNumber) $this->objArticlemusictracks->DiscNumber = $this->txtDiscNumber->Text;
				if ($this->txtTrackNumber) $this->objArticlemusictracks->TrackNumber = $this->txtTrackNumber->Text;
				if ($this->txtTrackTitle) $this->objArticlemusictracks->TrackTitle = $this->txtTrackTitle->Text;

				// Update any UniqueReverseReferences (if any) for controls that have been created for it

				// Save the Articlemusictracks object
				$this->objArticlemusictracks->Save();

				// Finally, update any ManyToManyReferences (if any)
			} catch (QCallerException $objExc) {
				$objExc->IncrementOffset();
				throw $objExc;
			}
		}

		/**
		 * This will DELETE this object's Articlemusictracks instance from the database.
		 * It will also unassociate itself from any ManyToManyReferences.
		 */
		public function DeleteArticlemusictracks() {
			$this->objArticlemusictracks->Delete();
		}		



		///////////////////////////////////////////////
		// PUBLIC GETTERS and SETTERS
		///////////////////////////////////////////////

		/**
		 * Override method to perform a property "Get"
		 * This will get the value of $strName
		 *
		 * @param string $strName Name of the property to get
		 * @return mixed
		 */
		public function __get($strName) {
			switch ($strName) {
				// General MetaControlVariables
				case 'Articlemusictracks': return $this->objArticlemusictracks;
				case 'TitleVerb': return $this->strTitleVerb;
				case 'EditMode': return $this->blnEditMode;

				// Controls that point to Articlemusictracks fields -- will be created dynamically if not yet created
				case 'IdControl':
					if (!$this->lblId) return $this->lblId_Create();
					return $this->lblId;
				case 'IdLabel':
					if (!$this->lblId) return $this->lblId_Create();
					return $this->lblId;
				case 'ReferenceIdControl':
					if (!$this->lstReferenceIdObject) return $this->lstReferenceIdObject_Create();
					return $this->lstReferenceIdObject;
				case 'ReferenceIdLabel':
					if (!$this->lblReferenceId) return $this->lblReferenceId_Create();
					return $this->lblReferenceId;
				case 'DiscNumberControl':
					if (!$this->txtDiscNumber) return $this->txtDiscNumber_Create();
					return $this->txtDiscNumber;
				case 'DiscNumberLabel':
					if (!$this->lblDiscNumber) return $this->lblDiscNumber_Create();
					return $this->lblDiscNumber;
				case 'TrackNumberControl':
					if (!$this->txtTrackNumber) return $this->txtTrackNumber_Create();
					return $this->txtTrackNumber;
				case 'TrackNumberLabel':
					if (!$this->lblTrackNumber) return $this->lblTrackNumber_Create();
					return $this->lblTrackNumber;
				case 'TrackTitleControl':
					if (!$this->txtTrackTitle) return $this->txtTrackTitle_Create();
					return $this->txtTrackTitle;
				case 'TrackTitleLabel':
					if (!$this->lblTrackTitle) return $this->lblTrackTitle_Create();
					return $this->lblTrackTitle;
				default:
					try {
						return parent::__get($strName);
					} catch (QCallerException $objExc) {
						$objExc->IncrementOffset();
						throw $objExc;
					}
			}
		}

		/**
		 * Override method to perform a property "Set"
		 * This will set the property $strName to be $mixValue
		 *
		 * @param string $strName Name of the property to set
		 * @param string $mixValue New value of the property
		 * @return mixed
		 */
		public function __set($strName, $mixValue) {
			try {
				switch ($strName) {
					// Controls that point to Articlemusictracks fields
					case 'IdControl':
						return ($this->lblId = QType::Cast($mixValue, 'QControl'));
					case 'ReferenceIdControl':
						return ($this->lstReferenceIdObject = QType::Cast($mixValue, 'QControl'));
					case 'DiscNumberControl':
						return ($this->txtDiscNumber = QType::Cast($mixValue, 'QControl'));
					case 'TrackNumberControl':
						return ($this->txtTrackNumber = QType::Cast($mixValue, 'QControl'));
					case 'TrackTitleControl':
						return ($this->txtTrackTitle = QType::Cast($mixValue, 'QControl'));
					default:
						return parent::__set($strName, $mixValue);
				}
			} catch (QCallerException $objExc) {
				$objExc->IncrementOffset();
				throw $objExc;
			}
		}
	}
?>